/*

This do-file runs all the scripts to create the tables and figures in "Cluster Jackknife Instrumental Variables Estimation," by Frandsen, Leslie, and McIntyre.

Before running, update root directory filepath.



*/


local start_time_master = clock(c(current_date) + " " + c(current_time), "DMYhms")
display "Start time master: " %tcCCYY-NN-DD_HH:MM:SS `start_time_master'




global master "1"


****************************
*** UPDATE FILEPATH HERE ***
****************************
global root_dir /Users/andersee/Dropbox/cluster_jackknife/restat/cjive_replication_package
*****************************



*** subfolders
global raw_data  $root_dir/raw_data
global intermediate_data $root_dir/intermediate_data
global clean_data $root_dir/clean_data
global tabfig $root_dir/tabfig
global logfiles $root_dir/logfiles


*** Run simulations
do $root_dir/paper_simulations.do

*** Clean data for empirical example
do $root_dir/clean_Miami_data.do


*** Create tables and figures for empirical example
do $root_dir/analyze_Miami_data.do




* Calculate runtime of do-file
local end_time_master = clock(c(current_date) + " " + c(current_time), "DMYhms")
display "End time master: " %tcCCYY-NN-DD_HH:MM:SS `end_time_master'

	* Calculate time difference in milliseconds
	local duration_ms = `end_time_master' - `start_time_master'

	* Convert milliseconds to hours (1 hour = 3,600,000 ms)
	local duration_hours = `duration_ms' / 3600000

	* Display the result
	display "Duration master: " `duration_hours' " hours"
